/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = sybase_request.h                                              */
/*   TE      =                                                               */
/*  DATE      = 2015/05/27 by zhengxd                                         */
/******************************************************************************/
#ifndef _SYBASE_TOKEN_H_
#define _SYBASE_TOKEN_H_

#include "sybase_base_type.h"

#define FRTDS_BINARY       0x2D   //Binary
#define FRTDS_BIT          0x32   //Bit
#define FRTDS_BLOB         0x24   //Serialized Object
#define FRTDS_BOUNDARY     0x68   //Boundary
#define FRTDS_CHAR         0x2F   //Character
#define FRTDS_DATE         0x31   //Date
#define FRTDS_DATEN        0x7B   //Date
#define FRTDS_DATETIME     0x3D   //Date/time
#define FRTDS_DATETIMEN    0x6F   //Date/time
#define FRTDS_DECN         0x6A   //Decimal
#define FRTDS_FLT4         0x3B   //Float
#define FRTDS_FLT8         0x3E   //Float
#define FRTDS_FLTN         0x6D   //Float
#define FRTDS_IMAGE        0x22   //Image
#define FRTDS_INT1         0x30   //Unsigned Integer
#define FRTDS_INT2         0x34   //Integer
#define FRTDS_INT4         0x38   //Integer
#define FRTDS_INT8         0xbf   //Integer
#define FRTDS_INTERVAL     0x2E   //Time Interval
#define FRTDS_INTN         0x26   //Integer
#define FRTDS_LONGBINARY   0xE1   //Binary
#define FRTDS_LONGCHAR     0xAF   //Character
#define FRTDS_MONEY        0x3C   //Money
#define FRTDS_MONEYN       0x6E   //Money
#define FRTDS_NUMN         0x6C   //Numeric
#define FRTDS_SENSITIVITY  0x67   //Sensitivity
#define FRTDS_SHORTDATE    0x3A   //Date/time
#define FRTDS_SHORTMONEY   0x7A   //Money
#define FRTDS_SINT1        0xb0   //Signed Integer
#define FRTDS_TEXT         0x23   //Text
#define FRTDS_TIME         0x33   //Time
#define FRTDS_TIMEN        0x93   //Time
#define FRTDS_UINT2        0x41   //Unsigned Integer
#define FRTDS_UINT4        0x42   //Unsigned Integer
#define FRTDS_UINT8        0x43   //Unsigned Integer
#define FRTDS_UINTN        0x44   //Unsigned Integer
#define FRTDS_UNITEXT      0xae   //Unicode UTF-16 Text
#define FRTDS_VARBINARY    0x25   //Binary
#define FRTDS_VARCHAR      0x27   //Character
#define FRTDS_VOID         0x1f   //Void (unknown)
#define FRTDS_XML          0xA3   //XML

/* DataType */
typedef struct __st_sybase_data_type
{
    int i_data_type;
} Sybase_data_type;

/* ALTFMT */
typedef struct __st_sybase_altfmt
{
    int i_id;                           /* ID */
    Frlist_header *p_lst_data_type;     /* DataType list(Sybase_data_type *) */
} Sybase_altfmt;


void sybase_datatype_node_free(Frlist_node *p_st_node);

int sybase_parse_login_token(Frbyte_Packet *p_st_data
                             , int i_whole_flg
                             , L7session_sybase *p_st_session);

int sybase_parse_altfmt_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session
                              , Frlist_header *p_lst_altfmt);

int sybase_parse_altname_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session);

int sybase_parse_altrow_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session
                              , Frlist_header *p_lst_altfmt);

int sybase_parse_capability_token(Frbyte_Packet *p_st_data
                                  , int i_whole_flg
                                  , int i_req_resp
                                  , L7session_sybase *p_st_session);

int sybase_parse_colinfo_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session);

int sybase_parse_colinfo2_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session);

int sybase_parse_control_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session);

int sybase_parse_curclose_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , long *p_l_cursor_id
                               , char *p_cursor_name
                               , int *p_i_declare_flg);

int sybase_parse_curdeclare_token(Frbyte_Packet *p_st_data
                                  , int i_whole_flg
                                  , L7session_sybase *p_st_session
                                  , int *p_i_status
                                  , char **pp_statement
                                  , char *p_cursor_name);

int sybase_parse_curdeclare2_token(Frbyte_Packet *p_st_data
                                  , int i_whole_flg
                                  , L7session_sybase *p_st_session
                                  , int *p_i_status
                                  , char **pp_statement
                                  , char *p_cursor_name);

int sybase_parse_curdeclare3_token(Frbyte_Packet *p_st_data
                                  , int i_whole_flg
                                  , L7session_sybase *p_st_session
                                  , int *p_i_status
                                  , char **pp_statement
                                  , char *p_cursor_name);

int sybase_parse_curdelete_token(Frbyte_Packet *p_st_data
                                 , int i_whole_flg
                                 , L7session_sybase *p_st_session
                                 , long *p_l_cursor_id
                                 , char *p_cursor_name);

int sybase_parse_curfetch_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , long *p_l_cursor_id
                               , char *p_cursor_name);

int sybase_parse_curinfo_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , long *p_l_cursor_id
                               , char *p_cursor_name);

int sybase_parse_curinfo2_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , long *p_l_cursor_id
                               , char *p_cursor_name);

int sybase_parse_curinfo3_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session
                                , long *p_l_cursor_id
                                , char *p_cursor_name);

int sybase_parse_curopen_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , long *p_l_cursor_id
                               , char *p_cursor_name
                               , int *p_i_status);

int sybase_parse_curupdate_token(Frbyte_Packet *p_st_data
                                 , int i_whole_flg
                                 , L7session_sybase *p_st_session
                                 , long *p_l_cursor_id
                                 , char *p_cursor_name
                                 , char **pp_statement
                                 , int *p_i_status);

int sybase_parse_dbrpc_token(Frbyte_Packet *p_st_data
                             , int i_whole_flg
                             , L7session_sybase *p_st_session
                             , char **pp_rpc_name
                             , int *p_i_options);

int sybase_parse_dbrpc2_token(Frbyte_Packet *p_st_data
                             , int i_whole_flg
                             , L7session_sybase *p_st_session
                             , char **pp_rpc_name
                             , int *p_i_options);

int sybase_parse_done_token(Frbyte_Packet *p_st_data
                            , int i_whole_flg
                            , L7session_sybase *p_st_session
                            , int *p_i_err_flg
                            , unsigned long *p_ul_effect_rows);

int sybase_parse_doneproc_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session
                                , int *p_i_err_flg
                                , unsigned long *p_ul_effect_rows);

int sybase_parse_dynamic_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , int i_req_resp
                               , int *p_i_type
                               , int *p_i_status
                               , char *p_id
                               , char **pp_statement);

int sybase_parse_dynamic2_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , int i_req_resp
                               , int *p_i_type
                               , int *p_i_status
                               , char *p_id
                               , char **pp_statement);

int sybase_parse_eed_token(Frbyte_Packet *p_st_data
                           , int i_whole_flg
                           , L7session_sybase *p_st_session
                           , int *p_i_msg_num
                           , char **pp_msg_info);

int sybase_parse_envchange_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session);

int sybase_parse_error_token(Frbyte_Packet *p_st_data
                            , int i_whole_flg
                            , L7session_sybase *p_st_session
                            , int *p_i_error_num
                            , char **pp_error_msg);

int sybase_parse_eventnotice_token(Frbyte_Packet *p_st_data
                                   , int i_whole_flg
                                   , L7session_sybase *p_st_session);

int sybase_parse_info_token(Frbyte_Packet *p_st_data
                            , int i_whole_flg
                            , L7session_sybase *p_st_session
                            , int *p_i_error_num
                            , char **pp_error_ms);

int sybase_parse_key_token(Frbyte_Packet *p_st_data
                          , int i_whole_flg
                          , L7session_sybase *p_st_session
                          , Frlist_header *p_lst_metadata);

int sybase_parse_language_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , int *p_i_status
                               , char **pp_sql);

int sybase_parse_loginack_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , int *p_i_status);

int sybase_parse_logout_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg);

int sybase_parse_msg_token(Frbyte_Packet *p_st_data
                          , int i_whole_flg
                          , L7session_sybase *p_st_session);

int sybase_parse_offset_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session);

int sybase_parse_optioncmd_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session);

int sybase_parse_orderby_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session);

int sybase_parse_orderby2_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session);

int sybase_parse_paramfmt_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session
                                , Frlist_header *p_lst_metadata);

int sybase_parse_paramfmt2_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session
                                , Frlist_header *p_lst_metadata);

int sybase_parse_params_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session
                              , Frlist_header *p_lst_metadata
                              , int i_get_value
                              , Sql_field_bind **pp_lst_bind_hd);

int sybase_parse_rpc_token(Frbyte_Packet *p_st_data
                           , int i_whole_flg
                           , L7session_sybase *p_st_session
                           , char **pp_rpc_name
                           , Sql_field_bind **pp_lst_bind_hd);

int sybase_parse_returnstatus_token(Frbyte_Packet *p_st_data
                                    , int i_whole_flg
                                    , L7session_sybase *p_st_session);

int sybase_parse_returnvalue_token(Frbyte_Packet *p_st_data
                                  , int i_whole_flg
                                  , L7session_sybase *p_st_session);

int sybase_parse_row_token(Frbyte_Packet *p_st_data
                          , int i_whole_flg
                          , L7session_sybase *p_st_session
                          , Frlist_header *p_lst_metadata);

int sybase_parse_rowfmt_token(Frbyte_Packet *p_st_data
                                , int i_whole_flg
                                , L7session_sybase *p_st_session
                                , Frlist_header *p_lst_metadata);

int sybase_parse_rowfmt2_token(Frbyte_Packet *p_st_data
                               , int i_whole_flg
                               , L7session_sybase *p_st_session
                               , Frlist_header *p_lst_metadata);

int sybase_parse_tabname_token(Frbyte_Packet *p_st_data
                              , int i_whole_flg
                              , L7session_sybase *p_st_session);

#endif
